package com.aceleeyy.apb.base;

/**
 * API-响应码
 *
 * @author Ace Lee
 * @version 1.0
 * @date 2020/8/10 10:41
 **/
public enum ApbStatus {

    SUCCESS(100000, "请求成功!"),
    FAIL(999999, "请求失败!"),

    PARAMETER_ERROR(900001, "请求参数错误"),
    PARAMETER_EMPTY(900002, "请求参数为空"),
    NULL_POINTER_EXCEPTION(900003, "空指针异常"),
    BUSINESS_HANDLE_EXCEPTION(900004, "业务处理异常");

    private int code;

    private String desc;

    ApbStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    public static String explain(int code) {
        for (ApbStatus apbStatus : ApbStatus.values()) {
            if (apbStatus.code==code) {
                return apbStatus.desc;
            }
        }
        return "";
    }
}
